package indi.zhifa.study2024.nbr.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import indi.zhifa.core.common.web.entity.ann.ZhiFaRestController;
import indi.zhifa.study2024.nbr.gen.busy.domain.po.GenDomainEntity;
import indi.zhifa.study2024.nbr.logic.curd.domain.IDomainService;
import indi.zhifa.study2024.nbr.logic.curd.domain.entity.request.DomainAddRequest;
import indi.zhifa.study2024.nbr.logic.curd.domain.entity.request.DomainPageRequest;
import indi.zhifa.study2024.nbr.logic.curd.domain.entity.response.DomainAddResponse;
import indi.zhifa.study2024.nbr.util.Constant;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@Slf4j
@Validated
@RequiredArgsConstructor
@RequestMapping(value = Constant.ControllerBusyPrefix + "/domain")
@ZhiFaRestController
@Tag(name = "片区管理")
public class DomainController {
    private final IDomainService mDomainService;

    @Operation(summary = "添加片区")
    @PostMapping("/add")
    public DomainAddResponse addDomain(@Validated @RequestBody DomainAddRequest domainAddRequest) {
        return mDomainService.addDomain(domainAddRequest);
    }

    @Operation(summary = "片区分页")
    @PostMapping("/page")
    public Page<GenDomainEntity> page(@Validated @RequestBody DomainPageRequest pDomainPageRequest){
        return mDomainService.page(pDomainPageRequest);
    }

}
